package com.cj.controller;

import com.cj.Service.DeptService;
import com.cj.dao.DeptDao;
import com.cj.pojo.DeptPojo;
import com.cj.vo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/dept/")
public class DeptController {

    @Autowired
    DeptService deptService;

    // 返回页面
    @RequestMapping("index")
    public  String deptIndex(){
      return "pages/content/dept_list";
    }

    // 查询部门
    @RequestMapping("list")
    @ResponseBody
    public JsonResult deptList(Integer deptstatus){
        DeptPojo dp = new DeptPojo();
        dp.setDeptstatus(deptstatus);
        List<?> deptList = deptService.queryDpetByPojo(dp);
        return  new JsonResult(1,"成功" ,deptList);
    }
    // 修改部门
    @RequestMapping("updata")
    @ResponseBody
    public JsonResult deptUpdata(DeptPojo deptPojo){
        deptService.updataDept(deptPojo);
        return  new JsonResult(1,"成功" ,null);
    }

    @RequestMapping("add")
    @ResponseBody
    public JsonResult addUpdata(DeptPojo deptPojo){
        deptService.addDept(deptPojo);
        return  new JsonResult(1,"成功" ,null);
    }

}
